package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 登录类型
 *
 * @author ZuoLG
 */
@Getter
@AllArgsConstructor
public enum LoginTypeEnum {
  /** WEB */
  WEB("WEB", "WEB账号密码登录"),
  /** IdCard */
  ID_CARD("IDCARD", "身份证刷卡登录"),
  /** RFID */
  RFID("RFID", "RFID卡片登录");

  private String type;
  private String desc;

  public static LoginTypeEnum convert(String status) {
    return Arrays.stream(values())
        .filter(x -> x.type.equals(status))
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到登录类型：" + status));
  }
}
